package util

import (
	"github.com/lionsoul2014/ip2region/binding/golang/ip2region"
)

var (
	spIPRegion *ip2region.Ip2Region
)

func InitIPRegion() (err error) {
	if spIPRegion == nil {
		spIPRegion, err = ip2region.New("ip2region.db")
	}
	return
}

func GetIPRegion(ip string) (ret ip2region.IpInfo, err error) {
	ret, err = spIPRegion.MemorySearch(ip)
	return
}
